package com.hd.ssm.controller;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.hd.ssm.entity.User;
import com.hd.ssm.service.IUserService;

@Controller
public class LoginController {

    @Resource(name = "userService")
	private IUserService userService;

	@RequestMapping("/login.action")
	public String login(HttpServletRequest req, HttpServletResponse response) {

		// 此处调用服务层进行相应的业务操作
		String username = req.getParameter("username");
		String password = req.getParameter("password");
		User user = new User();
		user.setUsername(username);
		user.setPassword(password);
		user.setAge(0);

		System.out.println("当前用户信息: " + username + " " + password);

		int n = userService.checkUserExits(user);
		if (n != 0) {
			return "index";
		}
		return "error";
	}
}
